<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Carousel with scrollable cards</title>

    <!-- Sencha Touch CSS -->
    <link rel="stylesheet" href="../../resources/css/sencha-touch.css" type="text/css">

    <!-- Sencha Touch JS -->
    <script type="text/javascript" src="../../sencha-touch.js"></script>

    <!-- Application JS -->
    <script type="text/javascript" src="index.js"></script>
    <style>
        .x-fullscreen {
            background-color: white;
        }
        
        img.aligncenter {
        	display: block;
        	margin-left: auto;
        	margin-right: auto;
        	padding: 1px;
        }

        img.aligncenter,
        img.alignleft,
        img.alignright {
            border: 2px solid #ddd;
        	padding: 1px;
        }

        img.noborder {
            border: none !important;
        }

        .alignleft {
            float: left;
        }

        .alignright {
            float: right;
        }
        
        a.entry-title,
        .entry h2.post-title,
        .entry h2 a {
        	color:#1A5C9A;
        	/* font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; */
        	font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
        	font-weight: 600;
        	font-size: 20px;
        	line-height: 20px;
        }

        .entry h2.post-title {
            color: #111;

        }

        .entry h2.post-title,
        .entry h2 a {
            display: block;
            margin: 20px 0 0;
        }
        
        h4 {
        	margin-top:0;
        	font-size:11px;
        	font-weight:normal;
        	display:block;
        	letter-spacing: 0;
        	color:#999;
        	margin-bottom:10px;
        }
        
        .entry h2 {
        	font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
        	font-weight: 600;
        	letter-spacing: normal;
        }

        .entry h4 {
            font-size: 13px;
        }
        
        .entry strong {
            font-weight: bold;
        }

        .entry em {
            font-style: italic;
        }

        p,
        pre {
            margin: 0 0 12px;
        }
    </style>
</head>

<body>
    <div class="entry">
        <h2 class="post-title">Introducing Sencha Animator: The CSS3 Alternative to Flash</h2> 
        <p class="meta"><span class="date-header">October 26, 2010 by Michael Mullany</span></p>
                    
        <p><a href="/products/animator/"><img class="noborder alignright" src="http://www.sencha.com/assets/images/blog/20101026-animator.png" alt="Introducing Sencha Animator: The HTML5-CSS3 Alternative to Flash" height="249" width="250" /></a>Today we&rsquo;re thrilled to announce the developer preview release of Sencha Animator, a new GUI-based desktop application that enables interactive designers to easily create rich media animations for HTML5-capable devices. With Apple&#8217;s decision to exclude Flash from their iOS, interactive designers have been searching for a way to bring the power of web animation to iOS devices without hand-coding hundreds, if not thousands of lines of CSS3. Well, the search is over. <a href="/products/animator/">Check out our demos</a>, then <a href="http://www.sencha.com/products/animator/download.php">download Sencha Animator</a> and give it a whirl (you&#8217;ll need to <a href="http://www.sencha.com/forum/register.php">get a forum account</a> if you don&#8217;t already have one.)</p> 
        <h3>An Animation Power Tool</h3> 
        <p>Sencha Animator allows you simply place objects (text, shapes, and images) onto a re-sizable stage area, configure their properties and then animate to bring them to life. You can move, scale, skew and rotate objects singly or at various levels of nesting, in 2D or 3D space. With Sencha Animator, you can also take advantage of CSS3 capabilities like gradients, blurs, reflections and shadows. You can create basic animations quickly and easily. But Animator is also designed to be a CSS3 power-tool. So when you need to add HTML or custom CSS, it&rsquo;s easy to do that too. Best of all, Sencha Animator outputs pure CSS3 animation code, so it&rsquo;s hardware accelerated on Apple iOS, which creates incredibly smooth animations. This also means it&rsquo;s ready to work with any JavaScript library, not just Sencha.</p> 
        <h3>Web Animations &amp; CSS3 Ads</h3> 
        <p>There are two editions of Sencha Animator&mdash; Standard Edition and Ad Builder Edition. The Standard Edition (<a href="http://www.sencha.com/products/animator/download.php">today&rsquo;s preview release</a>) includes all the capabilities you need for normal web app animations. CSS Animations can replace Flash in many areas where it was once used: splash screens, educational content, motion graphics, kinetic typography, instructions, and more. Mobile designers and developers should be particularly thrilled since CSS3 animations are the only animation technology that works on the major mobile platforms- iOS, Android and Blackberry OS6. (Android lacks SVG and the BlackBerry Torch is not high powered enough to run Canvas).</p> 
        <p>However by license, the Standard Edition may not be used to create advertising, so if you&rsquo;re an advertising agency, you&rsquo;ll need to use our Ad Builder edition. If you&rsquo;re interested in this edition, contact us directly and we&rsquo;ll add you to a forthcoming private beta.</p> 
        <h3>How Much Does It Cost</h3> 
        <p>We&rsquo;re pricing standard edition like a traditional design tool: on a per user basis in the low hundreds of dollars. </p> 
        <h3>What&rsquo;s Coming Next</h3> 
        <p>Today&rsquo;s release is very much a preview release, and there are rough edges that will be sanded down before release. In our in-house usability testing, we&rsquo;ve identified several areas for improvement that we want to tackle. And of course, there are lots of CSS3 properties that we will bring into the application before we ship the final release: a better color picker, a gradient maker, more complete backgrounds support and more complete text formatting properties are just a few of the obvious features that you can expect. If you&rsquo;re a user of Sencha Touch or Sencha Designer, you can also expect some nice integration features. We also hope to expand support to non-Webkit browsers as they add appropriate support for the CSS3 Animation spec. </p> 
        <h3>And One Last Thing&hellip;</h3> 
        <p>For those of you wondering what Sencha Animator is written in, the answer is&hellip; Ext JS of course! Ext JS provided an enormous short-cut in development time and allowed us to deliver the product on multiple platforms without worrying about Objective-C or Windows APIs. </p> 
    </div>

    <div class="entry"> 
    	<h2 class="post-title">Make A JavaScript Formatter with V8 and jsbeautifier</h2> 
        <p class="meta"><span class="date-header">October 21, 2010 by Ariya Hidayat</span></p>
    
    	<p>If you&#8217;re a JavaScript developer, you should check out a handy online tool called <a href="http://jsbeautifier.org/">jsbeautifier.org</a>, written by Einar Lielmanis. By simply pasting your JavaScript code and clicking <b>Beautify</b>, the jsbeautifier tool automatically reformats and reindents your JavaScript code (or JSON snippets) based on spacing, packing, and other options that you can configure. </p> 
        <p>A great feature of jsbeautifier is that the formatter has a JavaScript API (check it out here <a href="http://github.com/einars/js-beautify/">http://github.com/einars/js-beautify/</a>), whose simple API call is <code>js_beautify(js_source_text, options)</code>. This returns the formatted version of <em>js_source_text</em> based on the settings passed in in <em>options</em>.</p> 
        <p>If you want to programmatically “beautify” local files, you can also run the jsbeautifier script from the command line. There is support for <a href="http://www.mozilla.org/rhino/">Rhino</a>, a JavaScript interpreter written in Java, to invoke the beautifier with the content of any file. Or if you&#8217;d prefer to not use Rhino, I recently added support for <a href="http://ariya.blogspot.com/2010/09/offline-command-line-beautifier-for.html">Qt Script</a> or <a href="http://ariya.blogspot.com/2010/10/yet-another-command-line-javascript.html">V8</a>. Qt Script is the <a href="http://doc.qt.nokia.com/4.7/qtscript.html">JavaScript engine</a> built into Qt, the multi-platform application framework from Nokia. <a href="http://v8.googlecode.com/">V8</a> is the JavaScript engine that powers Google Chrome.</p> 
        <p>In one of my previous blog posts, <a href="http://www.sencha.com/blog/2010/10/12/javascript-engines-how-to-compile-them/">JavaScript Engines: How to Compile Them</a>, I discussed how JavaScript engines can do more than just power a web browser. Today, I&#8217;ll use the V8-based beautifier as an example of how to embed V8 in a command-line application. </p> 
        <h3>Get the Code</h3> 
        <p>Let’s start by checking out the code, whic is as easy as:</p> 
        <pre>git clone git://github.com/einars/js-beautify.git
        cd js-beautify/v8</pre> 
        <p>What we want is in the <code>v8/</code> subdirectory.</p> 
        <p>Next, we need to compile V8, it should be under <code>lib/</code>. You can read <a href="http://www.sencha.com/blog/2010/10/12/javascript-engines-how-to-compile-them/">JavaScript Engines: How to Compile Them</a> for the details on this.</p> 
        <pre>svn checkout -r 5610 http://v8.googlecode.com/svn/trunk lib
        cd lib &amp;&amp; scons mode=release &amp;&amp; cd ..</pre> 
        <p>Note: We&#8217;re using V8 version 2.4.9 (revision 5610), earlier or later versions may have slightly different APIs.</p> 
        <p>When you&#8217;ve successfully compiled V8, you will get a static library: <code>lib/libv8.a</code>.</p> 
        <p>Next, compile the beautifer:</p> 
        <pre>g++ -o jsbeautify jsbeautify.cpp -Ilib/include/ -lv8 -Llib</pre> 
        <p>The resulting executable <code>jsbeautify</code> is the final tool.  Just place <code>jsbeautify</code> in your PATH to use it.</p> 
        <p>Now, you can set up your text editor to launch <code>jsbeautify</code> as an external application, and you have a handy auto-formatter! </p> 
        <p>Try out the tool by passing a file name as the argument, and the <em>beautified</em> contents will be printed out:</p> 
        <pre>./jsbeautify hello.js</pre> 
        <p>You can use the &#8211;overwrite option if you want to overwrite the original file. </p> 
        <h3>How It Works</h3> 
        <p>You&#8217;ll need a little background in C++ to understand the following code snippets (since V8 is written in C++). And to follow everything perfectly, you should also read the <a href="http://code.google.com/apis/v8/get_started.html">Getting Started Guide To V8</a> and the V8 <a href="http://code.google.com/apis/v8/embed.html">Embedder&#8217;s Guide</a>.</p> 
        <p>This is the annotated version of our tool:</p> 

        <div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">   <span style="color: #0000ff;">FILE</span><span style="color: #000040;">*</span> f <span style="color: #000080;">=</span> <span style="color: #0000dd;">fopen</span><span style="color: #008000;">&#40;</span>argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span>, <span style="color: #FF0000;">&quot;rb&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>f<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> 
                <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Error: unable to open file %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
                <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> 
            <span style="color: #008000;">&#125;</span> 
            <span style="color: #0000dd;">fseek</span><span style="color: #008000;">&#40;</span>f, <span style="color: #0000dd;">0</span>, <span style="color: #0000ff;">SEEK_END</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000ff;">int</span> len <span style="color: #000080;">=</span> <span style="color: #0000dd;">ftell</span><span style="color: #008000;">&#40;</span>f<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000dd;">rewind</span><span style="color: #008000;">&#40;</span>f<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> buf <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">char</span><span style="color: #008000;">&#91;</span>len <span style="color: #000040;">+</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000dd;">fread</span><span style="color: #008000;">&#40;</span>buf, <span style="color: #0000dd;">1</span>, len, f<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #0000dd;">fclose</span><span style="color: #008000;">&#40;</span>f<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div> 

        <p>The first thing the program does is read the input file (the name is passed as an argument to the program) and load the contents to a buffer (allocated from the heap). Nothing fancy here, just basic I/O (written for simplicity). Obviously, the buffer lives in the C++ world, so we need to transfer it to the JavaScript world so it can be accessed by the beautifier function.</p> 

        <div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    HandleScope handle_scope<span style="color: #008080;">;</span> 
            Handle<span style="color: #000080;">&lt;</span>ObjectTemplate<span style="color: #000080;">&gt;</span> global <span style="color: #000080;">=</span> ObjectTemplate<span style="color: #008080;">::</span><span style="color: #007788;">New</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            global<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Set<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;code&quot;</span>, String<span style="color: #008080;">::</span><span style="color: #007788;">New</span><span style="color: #008000;">&#40;</span>buf, len<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            Handle<span style="color: #000080;">&lt;</span>Context<span style="color: #000080;">&gt;</span> context <span style="color: #000080;">=</span> Context<span style="color: #008080;">::</span><span style="color: #007788;">New</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span>, global<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div> 

        <p>As mentioned in the V8 <a href="http://code.google.com/apis/v8/embed.html">Embedder&#8217;s Guide</a>, to use V8, we have  to prepare a handle scope, a global object, and an execution context. To pass the buffer content from C++ to JavaScript, we set the property called &#8216;code&#8217; in our global object to point to a new String object initialized with the buffer content. From this point, any JavaScript code running in the context can refer to and get the value of ‘code’.</p> 

        <div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    Context<span style="color: #008080;">::</span><span style="color: #007788;">Scope</span> context_scope<span style="color: #008000;">&#40;</span>context<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            Handle<span style="color: #000080;">&lt;</span>Script<span style="color: #000080;">&gt;</span> beautifyScript <span style="color: #000080;">=</span> Script<span style="color: #008080;">::</span><span style="color: #007788;">Compile</span><span style="color: #008000;">&#40;</span>String<span style="color: #008080;">::</span><span style="color: #007788;">New</span><span style="color: #008000;">&#40;</span>beautify_code<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            beautifyScript<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div> 

        <p>Context needs to be entered before we can use it, this is easily achieved using the context scope. After that, we compile the script which actually implements the js_beautify function and then immediately evaluate it.</p> 

        <div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    Handle<span style="color: #000080;">&lt;</span>Script<span style="color: #000080;">&gt;</span> runnerScript <span style="color: #000080;">=</span> Script<span style="color: #008080;">::</span><span style="color: #007788;">Compile</span><span style="color: #008000;">&#40;</span>String<span style="color: #008080;">::</span><span style="color: #007788;">New</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;js_beautify(code)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            Handle<span style="color: #000080;">&lt;</span>Value<span style="color: #000080;">&gt;</span> result <span style="color: #000080;">=</span> runnerScript<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div> 

        <p>At this stage, the JavaScript context already has access to an object (which is actually a string) named ‘code’ and a function ‘js_beautify’. So now we just need to connect the dots: evaluate “js_beautify(code)” and get the result. We also need to transfer the result, which still lives in the JavaScript world, back to our application’s C++ world:</p> 

        <div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>result.<span style="color: #007788;">IsEmpty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> <span style="color: #000040;">!</span>result<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>IsUndefined<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> 
                String<span style="color: #008080;">::</span><span style="color: #007788;">Utf8Value</span> str<span style="color: #008000;">&#40;</span>result<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
                <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #000040;">*</span>str<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
            <span style="color: #008000;">&#125;</span></pre></div></div> 

        <p>The final step is to print it out. And that’s all!</p> 
        <p>This example shows how you can quickly use V8 to wrap and execute a JavaScript function and turn it into a real-world tool. I hope it serves as a good start for you to explore the features of V8 as an embedded scripting engine!</p> 
    </div>

	<div class="entry"> 
        <h2 class="post-title">HTML5: The New Minimum for Mobile Web Devices</h2> 
        <p class="meta"><span class="date-header">October 15, 2010 by Michael Mullany</span></p>
                    
		<p><img class="noborder alignright" src="http://www.sencha.com/assets/images/blog/ios-android.jpg" alt="Apple iOS and Google Android devices lead the pack in mobile support for HTML5" />We designed Sencha Touch as a framework for building rich applications for HTML5-enabled mobile devices. Back in 2009 when we started our development, this meant Google Android 2+ and Apple iOS 2+ devices. Since then, these devices have been joined by the Apple iPad, the Blackberry Torch, the Blackberry Playbook tablet, the Google Android tablet, and the forthcoming WebOS based HP tablet and Nokia Meego phone.</p> 
        <p>Of course, we could have built something that worked on more primitive devices, but we chose not to do this for a variety of factors. The biggest being user experience and performance. You can&#8217;t build rich web apps on older devices that have basic browsers and incomplete and often buggy JavaScript. A rich app experience is the new minimum user expectation on mobile. </p> 
        <p>For this, we blame iPhone and Android. iPhone and Android native apps have set a new standard for mobile performance and experience. People <em>love</em> using these apps. And now it&#8217;s up to the mobile web to meet the new, higher, expectations. This means delivering web apps with polish, dynamism and performance. And the only way to do this in a mobile browser&mdash;without Flash&mdash;is with HTML5 family technologies.</p> 
        <h3>&#8220;Mobile is Not a Small Desktop&#8221;</h3> 
        <p>A mobile device is not just a small desktop. Taking something that works in a desktop browser with a mouse/keyboard interface and shrinking it down to mobile doesn&#8217;t cut it.  What&#8217;s different? Two things: limited screen real estate, and your finger is your only input device. These two things have deep design implications.</p> 
        <p>First, when screens are this small, <strong>even the simplest apps have to provide for fast and easy navigation through content and data</strong>. This means that the app has to pre-load content that falls outside the current view and bring it quickly onto the screen when needed. Ajax has made this very familiar to us on the desktop, but most legacy phones lack Ajax support. Should you really plan an app where you make a user wait for a page fetch every time you want to show new content? </p> 
        <p>And then there&#8217;s animation. When the screen is this small, animating navigation actions becomes very important. Animating a content transition tells the user where the new piece of content is located relative to previous content in the extended &#8220;content space&#8221;. Without animations, you will burn a lot of screen real estate with breadcrumbs and other location aids. </p> 
        <p>Finally, on-screen widgets on a touch-screen device have to be <strong>very large</strong> to allow for touch control. Apple Human Interface Guidelines recommend a 42 pixel minimum height for buttons. That&#8217;s a huge amount of real-estate taken up by navigation. If tapping buttons is the only way to get around your app, you&#8217;ll end up with screen-clutter: lots of UI widgets and a tiny amount of content. </p> 
        <p>However, if you have advanced gestures, you can reduce the amount of UI chrome. Android &amp; iOS native frameworks give you lots of tools for navigation without widget clutter:</p> 
        <ul> 
        <li>Components like carousels, that let you gesture directly on content areas for navigation</li> 
        <li>Complex gestures such as pinch/spread on content to zoom in/out</li> 
        <li>Modal dialogs and action sheets to confirm/cancel actions</li> 
        <li>Pop-over menus that overlay the main content area</li> 
        <li>Modal input widgets  - e.g. date spinners</li> 
        <li>And much more&#8230;</li> 
        </ul> 
        <p>Luckily, these native functions are also possible using a mobile web browser as long as it has a solid Javascript implementation and good CSS3 support. </p> 
        <h3>And Let&#8217;s Talk About Offline</h3> 
        <p>And we haven&#8217;t even talked about web apps that need geolocation or offline support. Being able to use a mobile app even when you&#8217;re on 3G in San Francisco (aka offline), means it needs to have local storage for both data and application assets. Again this requires HTML5. </p> 
        <p>By the beginning of next year, all new smart-phones from Apple, Android, RIM, and Nokia will be HTML5-ready. In market share terms, most of them will be cheap Android-powered HTML5 mobile devices. They&#8217;re already in the delivery pipeline of all the major carriers. This is why we chose the design strategy that we did. </p> 
    </div>   
</body>
</html>
